package com.forchange.project.core.hotcategorytop10review.dao

import com.forchange.project.core.bean.hotcategorytop10review.bean.UserVisitAction
import com.forchange.project.dao.TDAO
import org.apache.spark.rdd.RDD

/**
 * @Author chencong
 * @Description 资源连接层
 * @Date 3:33 下午 2021/6/27
 * @Param
 * */
class HotCategoryTOP10DAOReview extends TDAO{
  def getUserVisitction() ={
    //读取路径下的数据
    val fileRDD: RDD[String] = readFile("/Users/chencong/Desktop/spark_learning/input/user_visit_action.txt")

    //封装对象
    fileRDD
      .map(data=>{
        val datasArray: Array[String] = data.split("_")
        UserVisitAction(
          datasArray(0),
          datasArray(1),
          datasArray(2),
          datasArray(3),
          datasArray(4),
          datasArray(5),
          datasArray(6),
          datasArray(7),
          datasArray(8),
          datasArray(9),
          datasArray(10),
          datasArray(11),
          datasArray(12)
        )
      })
  }

  def main(args: Array[String]): Unit = {
    println(getUserVisitction())
  }

}
